// import path from "path";
const Components = require('unplugin-vue-components/webpack');
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers');

module.exports = {
  // 1.配置方式一: cli提供的方式
  // outputDir: "./build",
  // publicPath: "./",
  // 2.配置方式二: 和webpack属性完全一致, 最后会进行合并
  configureWebpack: {
    devtool: 'source-map',
    resolve: {
      // alias: {
      //   components: '@/components',
      // },
    },
    // dev 开始时生效
    devServer: {
      proxy: {
        '/api': {
          target: 'http://152.136.185.210:5000/',
          pathRewrite: {
            '^/api': ''
          },
          ws: true,
          changeOrigin: true
        }
      }
    },
    plugins: [
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  }
  // 会覆盖原来的属性, 不会合并.
  /* configureWebpack: (config) => {
    config.resolve.alias = {
      "@": path.resolve(__dirname, "src"),
      components: "@/components"
    };
  } */
  // 3.配置方式三:
  /* chainWebpack: (config) => {
    config.resolve.alias.set("@", path.resolve(__dirname, "src")).set("components", "@/components");
  } */
};
